package iscript.gameFramework.GameLite.content 
{

	internal class WatchGameContentEventList 
	{
		
		 private var _data:Vector.<WatchGameContentItem> = new Vector.<WatchGameContentItem>();
		 public function add(contentkey:String,keyFn:Function, processFn:Function):void {
			      var item:WatchGameContentItem = new WatchGameContentItem();
				      item.callbackFn = keyFn;
					  item.processFn = processFn;
					  item.contentkey = contentkey;
			          _data.push(item);
			 } 
			 
		 public function getWatchGameContentItem(contentkey:String, callbackFn:Function):Vector.<WatchGameContentItem> {
			        var data:Vector.<WatchGameContentItem> = new Vector.<WatchGameContentItem>();					
					for each ( var item:WatchGameContentItem in _data) {
						if( contentkey ==item.contentkey &&  callbackFn == item.callbackFn){
						   data.push(item);
						}
					}		
				   return data;
			 }	 
		 	 
		 public function remove(contentkey:String, callbackFn:Function):void {
			    if (_data.length == 0) return;
			    var removeIndexList:Vector.<int> = new Vector.<int>();
				var  item:WatchGameContentItem;
				var i:int;
			    for ( i = 0; i < _data.length; i++) 
				{
					item = WatchGameContentItem(_data[i])
					if( contentkey ==item.contentkey &&  callbackFn == item.callbackFn){
					   removeIndexList.push(i);
					}
				}
				removeIndexList.reverse();
				
				for ( i = 0; i < removeIndexList.length; i++) 
				{
					_data.splice(removeIndexList[i], 1);
				}				
			 }
		
	}

}


